<?php
#+------------------------------------------------------------------
#| 普通的。
#+------------------------------------------------------------------
#| Author:Janmas Cromwell <janmas-cromwell@outlook.com>
#+------------------------------------------------------------------
namespace form\element\form;

class Button implements ColumnInterface
{
    protected $class = [];

    protected $type  = 'submit';

    protected $text = '';

    protected $js = '';

    protected $loadJs = [];

    protected $loadCss = [];

    public function class($class)
    {
        $this->class = is_array($class) ? $class : [$class];
        return $this;
    }

    public function type(string $type)
    {
        $this->type = $type;
        return $this;
    }

    public function text(string $type)
    {
        $this->text = $type;
        return $this;
    }

    public function generate()
    {
        $class = implode(' ', $this->class);
        return <<<BUTTON
<button type="$this->type" class="btn $class">$this->text</button>
BUTTON;

    }

    /**
     * @return string
     */
    public function getJs(): string
    {
        return $this->js;
    }

    /**
     * @return array
     */
    public function getLoadJs(): array
    {
        return $this->loadJs;
    }

    /**
     * @return array
     */
    public function getLoadCss(): array
    {
        return $this->loadCss;
    }

    /**
     * @param string $js
     */
    protected function setJs(string $js): void
    {
        $this->js = $js;
    }

    /**
     * @param array $loadJs
     */
    protected function setLoadJs(array $loadJs): void
    {
        $this->loadJs = $loadJs;
    }

    /**
     * @param array $loadCss
     */
    protected function setLoadCss(array $loadCss): void
    {
        $this->loadCss = $loadCss;
    }

}